<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        td {
            padding: 0 20px;
            line-height: 45px;
            border: 1px solid #333;
        }
        table{
            border-collapse: collapse;
        }
    </style>
</head>

<body>
    
</body>
<script>
    //正左三角
    var n = 6, i = 1;
    while (i <= n) {
        var j = 1;
        while (j <= i) {
            document.write("星");
            j++;
        }
        document.write("<br>");
        i++;
    }
    document.write("<br>");

    //正右三角
    for (var i = 1; i <= n; i++) {
        for (var j = i; j <= n-1; j++) {
            document.write("&emsp;");
        }
        for (var k = 1; k <= i; k++) {
            document.write("星");
        }
        document.write("<br>");
    }
    document.write("<br>");

    

    //倒右三角
    var n = 6, i = 1;
    while (i <= n) {
        var j = 2;
        while (j <= i) {
            document.write("&emsp;");
            j++;
        }
        var k = i;
        while (k <= n) {
            document.write("星");
            k++;
        }
        document.write("<br>");
        i++;
    }
    document.write("<br>");

    //倒左三角
    var n = 6, i = 1;
    while (i <= n) {
        var j = i;
        while (j <= n) {
            document.write("星");
            j++;
        }
        document.write("<br>");
        i++;
    }
    document.write("<br>");

    //等腰三角形
    var n = 6, i = 1;
    while (i <= n) {
        var j = i;
        while (j <= n-1) {
            document.write("&emsp;");
            j++;
        }
        var k = 1;
        while (k <= i) {
            document.write("星");
            k++;
        }
        var l = 2;
        while (l <= i) {
            document.write("星");
            l++;
        }
        document.write("<br>");
        i++;
    }

    //等腰三角形
    var n = 5, i = 1;
    while (i <= n) {
        var j = 1;
        while (j <= i) {
            document.write("&emsp;");
            j++;
        }
        var k = i;
        while (k <= n) {
            document.write("星");
            k++;
        }
        var l = i;
        while (l <= n-1) {
            document.write("星");
            l++;
        }
        document.write("<br>");
        i++;
    }
    document.write("<br>");

    //九九乘法表
    var i, j;
    var z = 0;
    document.write("<table>");
    for (i = 1; i <= 9; i++) {
        document.write("<tr>");
        for (j = 1; j <= i; j++) {
            z = i * j;
            // str += j + " x " + i + " = " + z + "&emsp;";
            document.write("<td>");
            document.write(j + " x " + i + " = " + z);
            document.write("</td>");
        }
        document.write("</tr>");
        // str = str + "<br>";
    }
    document.write("</table>");
</script>

</html>